package com.jjq.movebooking.controller;


import com.jjq.movebooking.entity.MoveBooking;
import com.jjq.movebooking.service.MoveBookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class MoveBookingController {

    @Autowired
    private MoveBookingService moveBookingService;

    @RequestMapping("/AllList")
    public String AllList(Model model){
        List<MoveBooking> list=moveBookingService.list();
        model.addAttribute("list",list);
        return "list";
    }

    @RequestMapping("/details")
    public String details(Integer id,Model model){
        MoveBooking moveBookingId=moveBookingService.getById(id);
        model.addAttribute("moveId",moveBookingId);
        return "details";
    }
    @RequestMapping("/HandleUpdate")
    public  String HandleUpdate(Integer id,Model model){
        MoveBooking moveBookingId=moveBookingService.getById(id);
        model.addAttribute("moveId",moveBookingId);
        return "update";
    }

    @RequestMapping("/HandleUpdate2")
    public  String HandleUpdate2(MoveBooking moveBooking){
        moveBookingService.updateById(moveBooking);
        return "redirect:AllList";
    }
    @RequestMapping("/order")
    public String order(){
        return "order";
    }
    @RequestMapping("/orderAdd")
    public  String orderAdd(MoveBooking moveBooking){
        moveBooking.setId(null);
        moveBooking.setStatus(0);
        moveBookingService.save(moveBooking);
        return "redirect:AllList";
    }


}
